<template>
  <div class="myDiv">
     <!-- 烈士遗属 -->
    <el-card class="box-card secordCard" shadow="never">
      <div slot="header" class="clearfix">
        <span>烈士遗属信息</span>
        <!-- <el-button style="float: right; padding: 3px 0" type="text">收起</el-button> -->
      </div>
      <div>
        <el-form :model="form" ref="form" :rules="rules" :inline="true" class="formWidth" label-width="140px">
          <el-row :gutter="10">
            <el-col :span="8">
              <el-form-item label="与烈士关系" prop="relation">
                <el-select v-model="form.relation" placeholder="请选择与烈士关系">
                  <el-option
                    v-for="dict in relationOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="是否是持证人" prop="isHolder">
                <el-select v-model="form.isHolder" placeholder="请选择是否是持证人">
                  <el-option
                    v-for="dict in isHolderOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="烈士证明书编号" prop="martyrCertificateCode">
                <el-input v-model="form.martyrCertificateCode" placeholder="请输入烈士证明书编号" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="孤老情况" prop="isLonely">
                <el-select v-model="form.isLonely" placeholder="请选择孤老情况">
                  <el-option
                    v-for="dict in isLonelyOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="孤儿情况" prop="isOrphan">
                <el-select v-model="form.isOrphan" placeholder="请选择孤儿情况">
                  <el-option
                    v-for="dict in isOrphanOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供养情况" prop="supportSituation">
                <el-select v-model="form.supportSituation" placeholder="请选择供养情况">
                  <el-option
                    v-for="dict in supportSituationOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供养单位" prop="supportUnit">
                <el-select v-model="form.supportUnit" placeholder="请选择供养单位">
                  <el-option
                    v-for="dict in supportUnitOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供养类型" prop="careSituation">
                <el-select v-model="form.careSituation" placeholder="请选择">
                  <el-option
                    v-for="dict in careSituationOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="享受待遇的证件" prop="treatmentCertificate">
                <el-input v-model="form.treatmentCertificate" placeholder="请输入享受待遇的证件" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="现就业状况" prop="employmentSituation">
                <el-select v-model="form.employmentSituation" placeholder="请选择现就业状况">
                  <el-option
                    v-for="dict in employmentSituationOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="烈士姓名" prop="martyrName">
                <el-input v-model="form.martyrName" placeholder="请输入烈士姓名" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="烈士性别" prop="martyrSex">
                <el-select v-model="form.martyrSex" placeholder="请选择烈士性别">
                  <el-option
                    v-for="dict in martyrSexOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="parseInt(dict.dictValue)"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="烈士出生日期" prop="martyrBirthDate">
                <el-date-picker clearable size="small"
                  v-model="form.martyrBirthDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择烈士出生日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="烈士入伍时间" prop="martyrEnlistedDate">
                <el-date-picker clearable size="small"
                  v-model="form.martyrEnlistedDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择烈士入伍时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="烈士生前单位" prop="martyrUnit">
                <el-input v-model="form.martyrUnit" placeholder="请输入烈士生前单位" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="牺牲日期" prop="martyrDeathDate">
                <el-date-picker clearable size="small"
                  v-model="form.martyrDeathDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择牺牲日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="评定烈士时间" prop="evaluationDate">
                <el-date-picker clearable size="small"
                  v-model="form.evaluationDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择评定烈士时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="评定单位" prop="evaluationUnit">
                <el-input v-model="form.evaluationUnit" placeholder="请输入评定单位" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="烈士安葬地" prop="burialPlace">
              <el-select v-model="form.burialPlace" placeholder="请选择烈士安葬地">
                <el-option
                  v-for="dict in burialPlaceOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="安葬详细地址" prop="detailBurialPlace">
                <el-input v-model="form.detailBurialPlace" placeholder="请输入安葬详细地址" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "martyrCard",
  data(){
    return {
      // 与烈士关系字典
      relationOptions: [],
      // 是否是持证人字典
      isHolderOptions: [],
      // 孤老情况字典
      isLonelyOptions: [],
      // 孤儿情况字典
      isOrphanOptions: [],
      // 供养情况字典
      supportSituationOptions: [],
      // 供养单位字典
      supportUnitOptions: [],
      // 字典
      careSituationOptions: [],
      // 现就业状况字典
      employmentSituationOptions: [],
      // 烈士性别字典
      martyrSexOptions: [],
      // 烈士安葬地字典
      burialPlaceOptions: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        relation: [
          { required: true, message: "与烈士关系不能为空", trigger: "change" }
        ],
        isHolder: [
          { required: true, message: "是否是持证人不能为空", trigger: "change" }
        ],
      }
    }
  },
  props:{
    soldierId: String,
  },
  mounted(){
    this.form.soldierId = this.soldierId
  },
  created() {
    this.getDicts("relation").then(response => {
      this.relationOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isHolderOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isLonelyOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.isOrphanOptions = response.data;
    });
    this.getDicts("support_situation").then(response => {
      this.supportSituationOptions = response.data;
    });
    this.getDicts("support_unit").then(response => {
      this.supportUnitOptions = response.data;
    });
    this.getDicts("care_situation").then(response => {
      this.careSituationOptions = response.data;
    });
    this.getDicts("employment_situation").then(response => {
      this.employmentSituationOptions = response.data;
    });
    this.getDicts("s_sex").then(response => {
      this.martyrSexOptions = response.data;
    });
    this.getDicts("burial_place").then(response => {
      this.burialPlaceOptions = response.data;
    });
  },
  methods:{
    validateForm(){
      return new Promise((resolve , reject) => {
        this.$refs.form.validate(valid => {
          if (valid) {
            resolve();
          } else reject();
        });
      })
    }
  },
}
</script>
<style lang="scss" scoped>
.box-card{
  margin-bottom: 16px;
}
::v-deep .secordCard .el-form-item__content {
   height: 36px;
}
</style>